<title>City</title>
<h2>City</h2>
<div id="view-content">
    <div class="row-fluid">
        <div class="span9">
            <div class="well span4">
                <?php if ($this->formErrors != null) { ?>
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                        <?= $this->formErrors[0] ?>
                    </div>
                <?php } ?>
                <?= $this->form ?>
            </div>
            <div class="well span8">
                <table class="table">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>City</th>
                            <th>State</th>
                            <th></th>
                        </tr>
                    </thead>
                    <?php
                    $index = 1;
                    foreach ($this->allCity as $city) :
                        ?>
                        <tr>
                            <td><?= $index ?></td>
                            <td><?= $city['name'] ?></td>
                            <td><?php
                                $stateId = $city['state_id'] - 1;
                                $stateName = '';
                                if ($stateId != -1) {
                                    $stateName = $this->allState[$stateId]['name'];
                                }
                                echo $stateName;
                                ?></td>
                            <td><a class="btn btn-small" href="<?= $this->url(array('id' => $city['id']), 'city-update'); ?>"><i class="icon-edit"></i> Edit</a></td>
                        </tr>
                        <?php
                        $index++;
                    endforeach;
                    ?>
                </table>
            </div>
        </div>
    </div>
</div>